import http from "@/api"

/**
 * 查询原料集合
 * @param type 类型 (0: 溶质, 1: 溶剂)
 * @param name 原料名称
 */
export const getMaterialList = (type: number, name?: string) => {
  return http.get<any>("/exp/sol/list", { type, name })
}

/**
 * 下载原料导入模板
 */
export const downloadMaterialTemplate = () => {
  return http.download("/exp/sol/template")
}

/**
 * 批量导入原料数据
 * @param formData 包含文件的 FormData 对象
 */
export const importMaterialData = (formData: FormData) => {
  return http.post<any>("/exp/sol/import", formData)
}

/**
 * 清除所有原料数据
 */
export const clearAllMaterialData = () => {
  return http.post<any>("/exp/sol/clear")
}

/**
 * 获取盘位详情
 * @param no 盘位号
 */
export const getPositionDetail = (no: number) => {
  return http.get<any>("/exp/sol/detail", { no })
}

/**
 * 保存盘位数据
 * @param data 盘位数据
 */
export const savePositionData = (data: any) => {
  return http.post<any>("/exp/sol/save", data)
}

/**
 * 修改原料数据
 * @param data 原料数据
 */
export const modifyPositionData = (data: any) => {
  return http.post<any>("/exp/sol/modify", data)
}

/**
 * 获取所有盘位列表
 */
export const getAllPositionsList = () => {
  return http.get<any>("/exp/sol/list")
}
